//
//  KeChengXueShengView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/17.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "KeChengXueShengView.h"

@implementation KeChengXueShengView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
    }
    return self;
}
- (void)initSubView{
    [self addSubview:self.tableList];
    [_tableList mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@0);
        make.right.equalTo(@0);
        make.top.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
}
- (UITableView *)tableList{
    if (!_tableList) {
        UITableView *tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, APP_HEIGHT-84) style:UITableViewStyleGrouped];
        tableView.delegate  =self;
        tableView.dataSource = self;
        tableView.backgroundColor = [UIColor whiteColor];
        [tableView registerClass:[KeChengNextCell class] forCellReuseIdentifier:@"KeChengNextCell"];
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _headerView = [[KeChengNextHeaderView alloc]init];
        _headerView.frame = CGRectMake(0, 0,self.frame.size.width, 131);
        tableView.tableHeaderView = _headerView;
        _tableList = tableView;
    }
    return _tableList;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 40;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    KeChengNextCell *cell = [tableView dequeueReusableCellWithIdentifier:@"KeChengNextCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[KeChengNextCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"KeChengNextCell"];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    if (indexPath.row%2 == 0) {
        cell.backgroundColor = [UIColor whiteColor];
    }else{
        cell.backgroundColor = [UIColorChange colorwithHexString:@"#F8F8F8"];
    }
    cell.index = (int)indexPath.row;
    [cell reloadViewLayout];
    UILabel *labelXueHaoLabel = (UILabel *)[cell viewWithTag:20];
    UILabel *labelNameLabel = (UILabel *)[cell viewWithTag:21];
    UILabel *labelGenderLabel = (UILabel *)[cell viewWithTag:22];
    UIImageView *labelDuiHaoImage = (UIImageView *)[cell viewWithTag:23];
    UILabel *labelScoreLabel = (UILabel *)[cell viewWithTag:24];
    labelXueHaoLabel.text = @"1023";
    labelNameLabel.text = @"徐哈哈";
    labelGenderLabel.text = @"男";
    labelScoreLabel.text = @"100";
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"点击了cell");
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (!_titleView) {
        _titleView = [[SJXQHeaderTitleView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, 44) andArray:@[@"学号",@"姓名",@"性别",@"联系人",@"电话",@"状态",@"入学日期",@"详情"]];
        _titleView.backgroundColor = CONTENTBACKCOLOR;
    }
    _titleView.frame = CGRectMake(0, 0, self.frame.size.width, 44);
    [_titleView reloadView];
    return _titleView;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *mainView = [[UIView alloc]init];
    return mainView;
}
@end
